package com.javasm.mb_store_api_final.giftsandgoods.goodsBrand.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.javasm.mb_store_api_final.giftsandgoods.goodsBrand.service.GgBrandService;
import com.javasm.mb_store_api_final.giftsandgoods.goodsBrand.dao.GgBrandDao;
import com.javasm.mb_store_api_final.giftsandgoods.goodsBrand.entity.GgBrand;
import com.javasm.mb_store_api_final.giftsandgoods.goodsBrand.vo.BrandVo;
import com.javasm.mb_store_api_final.giftsandgoods.goodsType.entity.GgGoodsType;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品管理-品牌管理(GgBrand)表服务实现类
 *
 * @author makejava
 * @since 2024-07-30 10:40:09
 */
@Service("ggBrandService")
public class GgBrandServiceImpl extends ServiceImpl<GgBrandDao, GgBrand> implements GgBrandService {

    @Resource
    GgBrandDao brandDao;
    @Override
    public List<GgBrand> getByTypeId(String typeId) {
        List<GgBrand> ggBrandList= brandDao.getByTypeId(typeId);
        return ggBrandList;
    }

    @Override
    public IPage<GgBrand> listByBrandName(BrandVo brandVo) {
        LambdaQueryWrapper<GgBrand> wrapper = new LambdaQueryWrapper<>();
        if (brandVo.getBrandName()!=null&&!brandVo.getBrandName().equals("")){
            wrapper.like(GgBrand::getBrandName,brandVo.getBrandName());
        }
        IPage<GgBrand> page=new Page<> (brandVo.getPageNum(),brandVo.getPageSize());
        page(page,wrapper);
        return page;
    }
}

